ABC136 C - Build Stairs
提出
code: python
n = int(input())
h = list(map(int, input().split()))
can = True
for i in range(0, n-1):
pass
else:
can = False
break
if (can):
if (h == sorted(h)):
print("Yes")
else:
print("No")
else:
print("No")
解答
code: python
n = int(input())
h = list(map(int,input().split()))
# 初手は必ず−1しておいた方が有利
for i in range(1, n-1):
print('No')
exit()
# Hiを1減らしたせいでHi-1の要素との関係が崩れていないか確認 print('No')
exit()
print('Yes')
code: python
n = int(input())
h = list(map(int, input().split()))
# 逆から見たら値を固定したまま検証できる
# 最小値を常に持って1引いても手前の数をその数以下にできない場合はNG
for i in range(n-1, 0, -1):
print("No")
exit()
print("Yes")
メモ
提出
code: python
n = int(input())
h = list(map(int, input().split()))
# 山を削っていくイメージ
# maxの地点を求めると計算量
# 再帰的